/**
 * Created by chensk740 on 2018/1/3.
 */
import {Component, Input, OnDestroy, OnInit, ViewEncapsulation} from '@angular/core';
import {ActivatedRoute, Router} from "@angular/router";
import {Subject} from 'rxjs';
import {ImageServeService} from "app/shared/service/image/image-serve.service";
import {ToolsService} from "@shared/service/tools/tools.service";

@Component({
  selector: 'video-item',
  templateUrl: './video-item.component.html',
  styleUrls: ['./video-item.component.scss'],
  encapsulation: ViewEncapsulation.None
})
export class VideoItemComponent implements OnInit, OnDestroy {
  public ngUnsubscribe: Subject<void> = new Subject<void>();
  @Input()  itemData;
  constructor(
              public route: ActivatedRoute,
              public imgService: ImageServeService,
              public router: Router,
              public toolsService: ToolsService
  ) {
  }

  /**
   * @description 获取图标
   * @param iconName 图标名
   * @author chensk740
   * @date 2018-1-11
   */
  getIcon(iconName: string) {
    return this.imgService.getIcon(iconName);
  }
  /**
   * @description 跳转播放分享视频
   * @param url 视频地址
   * @author chensk740
   * @date 2018-1-12
   */
  goVideoPlay(video) {
    if (video.contentType === 20) {
      this.router.navigate([`/video/category/${video.cateId}`, video.contentId]);
    } else {
      this.toolsService.presentConfirm('下载求苗APP，看更多精彩内容!');
    }
  }
  ngOnInit() {
  }


  ngOnDestroy() {
    this.ngUnsubscribe.next();
    this.ngUnsubscribe.complete();
  }
}
